{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>{{ chapter.name }} - 知识点管理</h2>
        <a href="{% url 'core:knowledge_point_create' %}?chapter_id={{ chapter.id }}" class="btn btn-primary"><i class="bi bi-plus-circle me-2"></i>添加知识点</a>
    </div>

    {% if knowledge_points %}
    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>序号</th>
                            <th>知识点名称</th>
                            <th>描述</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for kp in knowledge_points %}
                        <tr>
                            <td>{{ kp.order }}</td>
                            <td>{{ kp.name }}</td>
                            <td>{{ kp.description|truncatechars:50 }}</td>
                            <td>
                                <div class="btn-group" role="group">
                                    <a href="{% url 'core:knowledge_point_update' kp.id %}" class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil me-1"></i>编辑</a>
                                    <a href="{% url 'core:knowledge_point_delete' kp.id %}" class="btn btn-sm btn-outline-danger"><i class="bi bi-trash me-1"></i>删除</a>
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    {% else %}
    <div class="alert alert-info">
        暂无知识点数据，请点击上方"添加知识点"按钮创建新知识点。
    </div>
    {% endif %}

    <div class="mt-3">
        <a href="{% url 'core:chapter_list' %}" class="btn btn-outline-secondary"><i class="bi bi-arrow-left me-2"></i>返回章节列表</a>
    </div>
</div>
{% endblock %}